home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / C / Comet2.1.3.cpt / 3270XCMD / TNConnect.c < prev    next >
Text File  |  1989-08-23  |  2KB  |  99 lines

  1. /* TNConnect.c -- XCMD to open the TN3270 driver 
  2.     copyright 1989 Cornell University 
  3.     
  4.     TNConnect hostid:  Connect to a host.
  5.  
  6. */
  7.  
  8.  
  9. #include <Types.h>
  10. #include <Memory.h>
  11. #include <Devices.h>
  12. #include <HyperXCmd.h>
  13. #include <Errors.h>
  14.  
  15. #include <String.h>
  16.  
  17. #include "TNdrvr.h"
  18.  
  19.  
  20. pascal void debugger()    extern 0xA9FF;   
  21.  
  22.  
  23. pascal void TNConnect(hycp)
  24. XCmdPtr hycp;
  25. {
  26.     CntrlParam drvpb;
  27.     long * args;
  28.     Str255 pstr;
  29.     
  30.     if (hycp->paramCount != 2) {
  31.         sethand(&hycp->returnValue, "TNConnect TNID,hostname: need 2 arguments");
  32.         return;
  33.     }
  34.     
  35.     HLock((Handle) hycp->params[0]);
  36.     HLock((Handle) hycp->params[1]);
  37.     
  38.     ZeroToPas(hycp, *hycp->params[0], (StringPtr) &pstr[0]);
  39.     drvpb.ioCRefNum = (short) StrToNum(hycp, (Str31 *) &pstr[0]);
  40.     drvpb.csCode = HTN_CONNECT;
  41.     args = (long *) &drvpb.csParam[0];
  42.     *args = * (long *) hycp->params[1];
  43.         /* pass the host id string to the drvr to pass on to TN3270 */
  44.     PBControl((ParmBlkPtr) &drvpb, (Boolean) 0);
  45.  
  46.     if (drvpb.ioResult) {
  47.         /* connect call failed */
  48.         switch (drvpb.ioResult) {
  49.             case HTNR_NOTN: {
  50.                 sethand(&hycp->returnValue, "TN is not running");
  51.                 break;
  52.             }
  53.             case HTNR_ACTIVE: {
  54.                 sethand(&hycp->returnValue, "TN not opened");
  55.                 break;
  56.             }
  57.             case HTNR_OPEN: {
  58.                 sethand(&hycp->returnValue, "TN already has a connection");
  59.                 break;
  60.             }
  61.             case HTNR_NAME: {
  62.                 sethand(&hycp->returnValue, "Name not in host table");
  63.                 break;
  64.             }
  65.             case HTNR_ADDR: {
  66.                 sethand(&hycp->returnValue, "Invalid Internet Address");
  67.                 break;
  68.             }
  69.             case badUnitErr: {
  70.                 sethand(&hycp->returnValue, "TNID is incorrect");
  71.                 break;
  72.             }
  73.             default: {
  74.                 sethand(&hycp->returnValue, "Unknown error");
  75.                 break;
  76.             }
  77.         }
  78.     }
  79.     HUnlock((Handle) hycp->params[0]);
  80.     HUnlock((Handle) hycp->params[1]);
  81.     return;
  82. }
  83.  
  84.  
  85. sethand(thand, str)
  86. Handle * thand;
  87. char * str;
  88. {
  89.     if (*thand == NULL) {
  90.         *thand = NewHandle((Size) 0);
  91.     }
  92.     SetHandleSize(*thand, (long) (strlen(str) + 1));
  93.     strcpy(**thand, str);
  94. }
  95.  
  96.  
  97.  
  98.  
  99. #include <XCmdGlue.inc.c>